package cn.com.fuhuitong.main.order.ui.activity

import android.app.Activity
import android.content.Intent
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.viewpager.widget.ViewPager
import cn.com.fuhuitong.app.AppConstance
import cn.com.fuhuitong.aroute.ARouteConstance
import cn.com.fuhuitong.main.base.ViewModeActivity
import cn.com.fuhuitong.main.order.adapter.OVT
import cn.com.fuhuitong.main.order.adapter.OrderTabAdapter
import cn.com.fuhuitong.main.order.ui.fragment.OrderListFragment
import cn.com.fuhuitong.main.order.vm.OrderViewModel
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import cn.com.fuhuitong.R
import cn.com.fuhuitong.base.ActivityCollector
import cn.com.fuhuitong.entity.MainBean
import cn.com.fuhuitong.entity.PayType
import cn.com.fuhuitong.main.goods.ui.activity.GoodsDetailsActivity
import cn.com.fuhuitong.utils.SpanUtils
import com.alibaba.android.arouter.launcher.ARouter
import kotlinx.android.synthetic.main.activity_order_list.*
import kotlinx.android.synthetic.main.activity_order_pay_complete.*

@Route(path = ARouteConstance.ACTIVITY_URL_ORDER_PAY_COMPLETE)
class OrderCompleteActivity : ViewModeActivity<OrderViewModel>() {

    override fun viewModel(): OrderViewModel = createViewModel()

    override val layoutResId: Int
        get() = R.layout.activity_order_pay_complete

    override fun initView() {

        val mainBean: MainBean<*, *> = intent?.getSerializableExtra(AppConstance.BUNDLE_PAY_MAIN)
                as MainBean<*, *>

        val payType: PayType = mainBean.type as PayType
        val payPrice: String = mainBean.data as String

        text_order_pay_complete_type.text = payType.desc
        text_order_pay_complete_price.text =
            SpanUtils.decimalFormat(payPrice.toDouble())

        image_order_complete_back.setOnClickListener {
            onBackPressed()
        }
        text_order_pay_complete_back.setOnClickListener {
            ARouter.getInstance().build(ARouteConstance.ACTIVITY_URL_MAIN)
                .navigation()
            this.finish()
        }
        text_order_pay_complete_look.setOnClickListener {
            ARouter.getInstance().build(ARouteConstance.ACTIVITY_URL_ORDER_LIST)
                .withInt(AppConstance.BUNDLE_ORDER_STATUS, 2)
                .navigation()
            this.finish()
        }
    }

    override fun onBackPressed() {
        super.onBackPressed()
//        ARouter.getInstance().build(ARouteConstance.ACTIVITY_URL_GOODS_DETAILS)
//            .navigation()
        setResult(RESULT_OK, Intent(this, OrderPayWaitActivity::class.java))
        this.finish()
    }


}